<template>
	<view class="bookshelf">
		<uni-nav-bar title="分类"></uni-nav-bar>
		<uni-card>
			<text>按热门分类</text>
			<view class="category">
				<navigator v-for="(item,index) in categories" 
				:key = index
				:url="`../bookList/bookList?title=${item.description}&category=${item.category}`">
				<button type="default">{{item.description}}</button>
				</navigator>
				
				<!-- <navigator url="../bookList/bookList?title=都市"><button type="default">都市</button></navigator>
				<navigator url="../bookList/bookList?title=都市"><button type="default">玄幻</button></navigator>
				<navigator url="../bookList/bookList?title=都市"><button type="default">历史</button></navigator>
				<navigator url="../bookList/bookList?title=都市"><button type="default">科幻</button></navigator>
				<navigator url="../bookList/bookList?title=都市"><button type="default">悬疑</button></navigator>
				<navigator url="../bookList/bookList?title=都市"><button type="default">网游</button></navigator>
				<view class="button"><button type="default">都市</button></view>
				<view class="button"><button type="default">玄幻</button></view>
				<view class="button"><button type="default">历史</button></view>
				<view class="button"><button type="default">科幻</button></view>
				<view class="button"><button type="default">悬疑</button></view>
				<view class="button"><button type="default">网游</button></view> -->
			</view>

		</uni-card>
		
	</view>
</template>

<script>
	import {reactive} from 'vue'
	import {fetchMenu} from "../../api/api.js"
	export default {
		data() {
			return {

			};
		},
		setup() {
			const categories = reactive([])
			
			fetchMenu()
			.then(res => {
				console.log(res.data.data)
				for (let s of res.data.data) {
					categories.push(s)
				}
			});
			
			return {
				categories
			}
		}
	}
</script>

<style lang="scss">
	.bookshelf {
		text {
			font-weight: bold;
			font-size: 18px;
			margin: 20rpx 0;
			margin-bottom: 40rpx;
		}
		.category {
			flex-direction: row;
			flex-wrap: wrap;
			display: flex;
			justify-content: space-around;

			.navigator-wrap {
				flex-basis: 40%;
				margin: 15rpx 0;
			}
		}
	}
</style>
